// 学术js
var $scope = null;
$(function() {
	var appElement = document.querySelector('[ng-controller=main]');
	$scope = angular.element(appElement).scope();
	  initialPage($scope);
	  //学者列表
	$scope.methods.expertList();
	// 学术作品
	$scope.methods.portfolioList();
});
// 初始化值
function initialPage($scope) {
	
	
}
var mainApp = angular.module("mainApp", []);
mainApp.controller('main', function($scope) {
	$scope.search={};
	$scope.methods = {
		//学者列表
		expertList : function() {
			$.ajax({
			    url:$.shysUrlPrefix+'/website/expertList',
			    type:'get',
			    dataType:'JSON',
				async:true,  //同步方式发起请求
				  beforeSend: function () {
				        $(".loading").show();
				    },
			    success:function (data) {
					console.log(data.data)
					if (data.data != null && data.data.length > 0 ) {  
					  $.each(data.data,function(i,item){
						if(data.data[i].photos){
					  			data.data[i].photos=data.data[i].photos+'?x-oss-process=image/watermark,color_FFFFFF,text_QOahpeaigeWcqOe6vw/resize,m_fill,h_300,w_240' 
					  	}	
					  										 
					  }),
					  $scope.expertList = data.data;
					   $scope.$apply();
					} else {
					   
					}
					
			    },
				 complete: function () {
				        $(".loading").hide();
				    },
			
			})
		},
		//学术作品
		portfolioList: function() {
			$.ajax({
			    url:$.shysUrlPrefix+'/website/portfolioList',
			    type:'get',
			    dataType:'JSON',
				async:true,  //同步方式发起请求
				  beforeSend: function () {
				        $(".loading").show();
				    },
			    success:function (data) {
					if (data.data != null  ) {
					$scope.portfolioList = data.data.portfolioList;
					$.each(data.data.portfolioList,function(i,item){
											if(data.data.portfolioList[i].cover){
								data.data.portfolioList[i].cover=data.data.portfolioList[i].cover+'?x-oss-process=image/watermark,color_FFFFFF,text_QOahpeaigeWcqOe6vw/resize,p_70' 
						}	
															 
					}),
					$scope.artworkTotalNum = data.data.artworkTotalNum;
					 console.log(data.data)
					   $scope.$apply();
					} else {
					   
					}
					
			    },
				 complete: function () {
				        $(".loading").hide();
				    },
			
			})
		},
		// 更多学者
		moreExpert: function () {
		 window.location.href="academic-people.html"
		},
		// 更多学术
		newsMore: function () {
		 window.location.href="academic-people.html"
		},
		// 作品详情展示
		labelDetailClick: function (label) {
		 console.log(label)
		 window.location.href="academic-activity.html?portfolioId="+label.id
		},
		
	};
});











